package com.ms.demo;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: Employee类
 * @author: ms
 * @create: 2022-10-26 10:27
 */
public class Employee {

    private String name;                 //姓名
    private String dept;                 //部门
    private int salary;                  //工资
    private List<Employee> subordinates; //下属

    //构造函数
    public Employee(String name,String dept, int sal) {
        this.name = name;
        this.dept = dept;
        this.salary = sal;
        subordinates = new ArrayList<Employee>();
    }

    public void add(Employee e) {
        subordinates.add(e);
    }

    public void remove(Employee e) {
        subordinates.remove(e);
    }

    public List<Employee> getSubordinates(){
        return subordinates;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", dept='" + dept + '\'' +
                ", salary=" + salary +
                ", subordinates=" + subordinates +
                '}';
    }
}